import java.util.StringTokenizer;


class P11244_39643 {

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}


	public static void main(String[] args) {
		
		try {
		
		while (true) {
			StringTokenizer st = new StringTokenizer(readLn());
			
			int r = Integer.parseInt(st.nextToken()); 
			int c = Integer.parseInt(st.nextToken());
			
			if (r == 0 && c == 0) break;
			
			process(r, c);
			
		}
		} catch (Exception e) {
			while (true) {
				
			}
		}
	}


	private static void process(int r, int c) {
		char[][] sky = new char[r][c];
		
		for (int k = 0; k < r; k++) {
			String line = readLn();
			
			for (int j = 0; j < c; j++) {
				sky[k][j] = line.charAt(j);
			}
		}
		
//		System.out.println("-----");
//		
//		for (int k = 0; k < r; k++) {
//			for (int j = 0; j < c; j++)
//				System.out.print(sky[k][j]);
//			System.out.println();
//		}
//		System.out.println("-----");
		
		int stars = 0;
		for (int k = 0; k < r; k++) {
			for (int j = 0; j < c; j++) {
				if (sky[k][j] == '*') {
					if (isStar(k, j, sky)) stars++;
					else notStar(k, j, sky);
				}
			}
		}
		
//		System.out.println("-----");
//		
//		for (int k = 0; k < r; k++) {
//			for (int j = 0; j < c; j++)
//				System.out.print(sky[k][j]);
//			System.out.println();
//		}
//		System.out.println("-----");
		
		System.out.println(stars);
		
	}


	private static void notStar(int k, int j, char[][] sky) {
		
//		System.out.println("k=" + k + " " + "j="+j);
		
		sky[k][j] = '0';
		
		if (k - 1 >= 0 && sky[k-1][j] == '*') notStar(k-1,j,sky);
		if (j - 1 >= 0 && sky[k][j-1] == '*') notStar(k,j-1,sky);
		
		if (k + 1 < sky.length && sky[k+1][j] == '*') notStar(k+1,j,sky);
		if (j + 1 < sky[k].length && sky[k][j+1] == '*') notStar(k,j+1,sky);
		
		if (k - 1 >= 0 && j - 1 >= 0 && sky[k-1][j-1] == '*') notStar(k-1,j-1,sky);
		if (k + 1 < sky.length && j + 1 < sky[k].length && sky[k+1][j+1] == '*') notStar(k+1,j+1,sky);
		
		if (k + 1 < sky.length && j - 1 >= 0 && sky[k+1][j-1] == '*') notStar(k+1,j-1,sky);
		
//		System.out.println("k - 1 >= 0 => " + (k - 1) + " > 0 => " + (k - 1 >= 0)); 
//		System.out.println("j + 1 < sky[k].length => " + (j+1) + " < " + sky[k].length + " => " + (j + 1 < sky[k].length));  
//		
		if (k - 1 >= 0 && j + 1 < sky[k].length && sky[k-1][j+1] == '*') notStar(k-1,j+1,sky);
		
	}


	private static boolean isStar(int k, int j, char[][] sky) {
		
		if (k - 1 >= 0 && sky[k-1][j] == '*') return false;
		if (j - 1 >= 0 && sky[k][j-1] == '*') return false;
		
		if (k + 1 < sky.length && sky[k+1][j] == '*') return false;
		if (j + 1 < sky[k].length && sky[k][j+1] == '*') return false;
		
		if (k - 1 >= 0 && j - 1 >= 0 && sky[k-1][j-1] == '*') return false;
		if (k + 1 < sky.length && j + 1 < sky[k].length && sky[k+1][j+1] == '*') return false;
		
		if (k + 1 < sky.length && j - 1 >= 0 && sky[k+1][j-1] == '*') return false;
		if (k - 1 >= 0 && j + 1 < sky[k].length && sky[k-1][j+1] == '*') return false;
		
		return true;
	}
	
}
